/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ufscar.compiladores.ast;

/**
 *
 * @author takeshi
 */
public class PrintCommand extends Command{
    
    private Expr expr;
    
    public PrintCommand(Expr expr) {
        this.expr = expr;
    }
    
    @Override
    public void genC(PW pw) {
        if (expr.getType() == Type.booleanType) {
            pw.print("printf(\"%s\\n\", ");
            expr.genC(pw, false);
            pw.out.print(" ? \"True\" : \"False\"");
        } else {
            pw.print("printf(\"%d\\n\", ");
            expr.genC(pw, false);
        }
        pw.out.println(" );");
    }
    
}
